import { getPiex } from "../tools/baseTools";
import memoryData, { updateConstructionSiteBuildAmount } from "../tools/memoryData";
import autoBuildManager from "./autoBuild/autoBuildManager";
import progressManager from "./progressManager";


const scheduleManager = {
    init: () => {
        progressManager.checkSelf()         // 建筑物自检
        progressManager.pushTask()          // 根据state属性推送任务
        autoBuildManager.checkSelf()
        getPiex()                           // 兑换像素点
    },
    /**定时任务管理器 */
    run: function (params, options = {}) {
        const { minShortTick = 10, shortTick = 60, mediumTick = 599, longTick = 3594 } = options
        // 定时器逻辑--超短间隔
        if (Game.time % minShortTick == 0) {    // "超短间隔定时任务"默认是10tick
            // console.log(`${Date()} :开始执行短间隔时长为${minShortTick}的中间隔定时任务`);
        }

        // 定时器逻辑--短间隔
        if (Game.time % shortTick == 0) {   // "短间隔定时任务"默认是一分钟
            // console.log(`${Date()} :开始执行短间隔时长为${shortTick}的中间隔定时任务`);
            progressManager.checkSelf()      // 建筑物自检
            memoryData.updateData()
        }

        // 定时器逻辑--中间隔
        if (Game.time % mediumTick == 0) {  // "中间隔定时任务"默认是十分钟
            console.log(`${Date()} :开始执行短间隔时长为${mediumTick}的中间隔定时任务`);
            autoBuildManager.checkSelf()
            progressManager.pushTask()          // 根据state属性推送任务
            getPiex()                           // 兑换像素点
        }

        // 定时器逻辑--长间隔
        if (Game.time % longTick == 0) {
            console.log(`${Date()} :开始执行短间隔时长为${longTick}的长间隔定时任务`);
        }
    }
}


export default scheduleManager